//
//  EPHud.swift
//  EPHome
//
//  Created by liujianlong on 2022/8/25.
//

import UIKit

class EPHud: EPAlertViewController {
    @IBOutlet weak var bgView: UIView!
    @IBOutlet weak var content: UILabel!
    var dismisstime:Int = 0
    override func viewDidLoad() {
        super.viewDidLoad()
    }
 
    ///必须要加上这个方法，否则self.modalPresentationStyle = .overFullScreen不生效
    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        self.view.layoutIfNeeded()
        self.modalPresentationStyle = .overFullScreen
        self.view.backgroundColor = "#000000".color(0.6)
        self.view.backgroundColor = .clear
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .seconds(self.dismisstime)) {
            self.dismiss(animated: false)
        }
    }
    class func hud(_ content:String, _ dismisstime:Int){
        let vc = self.init()
        vc.content.text = content
        vc.dismisstime = dismisstime
        vc.currentVC().present(vc, animated:false)
    }

}
